//
//  CXIngredientCollectionViewCell.m
//  Delicious
//
//  Created by dllo on 15/11/27.
//  Copyright © 2015年 doll. All rights reserved.
//

#import "CXIngredientCollectionViewCell.h"
#import "CXIngreModel.h"
#import "UIImageView+WebCache.h"


@interface CXIngredientCollectionViewCell ()

@property (nonatomic, retain) UIView *alphaView;
@property (nonatomic, retain) UIImageView *PictureView;
@property (nonatomic, retain) UILabel *nameLabel;

@end


@implementation CXIngredientCollectionViewCell

#pragma mark -- 初始化
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.PictureView = [[UIImageView alloc] init];
        self.PictureView.backgroundColor = [UIColor cyanColor];
        self.PictureView.clipsToBounds = YES;
        self.PictureView.layer.cornerRadius = 40;
        self.PictureView.layer.borderWidth = 2;
        self.PictureView.layer.borderColor = [UIColor grayColor].CGColor;
        [self.contentView addSubview:self.PictureView];
        
        self.alphaView = [[UIView alloc] init];
        self.alphaView.backgroundColor = [UIColor blackColor];
        self.alphaView.alpha = 0.6;
        self.alphaView.clipsToBounds = YES;
        self.alphaView.layer.cornerRadius = 10;
        [self.PictureView addSubview:self.alphaView];
        
        self.nameLabel = [[UILabel alloc] init];
        self.nameLabel.backgroundColor = [UIColor clearColor];
        self.nameLabel.font = [UIFont systemFontOfSize:12];
        self.nameLabel.textColor = [UIColor whiteColor];
        [self.PictureView addSubview:self.nameLabel];
        
        
        
    }
    return self;
}

#pragma mark -- 空间布局
-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes

{
    self.PictureView.frame = CGRectMake(0, 0, 80, 80);
    self.alphaView.frame = CGRectMake(20, 30, 40, 20);
    self.nameLabel.frame = CGRectMake(25, 32, 30, 15);
}

#pragma mark --赋值
- (void)setMessage:(CXIngreModel *)message
{
    self.nameLabel.text = message.name;
    [self.PictureView sd_setImageWithURL:[NSURL URLWithString:message.img] placeholderImage:[UIImage imageNamed:@""]];
    
    
}

@end
